"""
Case Type   : 行存压缩
Case Name   : 行存压缩前置条件
Create At   : 2024/11/25
Owner       : @li-xin12345
Description :
    1、设置support_extended_features为on。
Expect      :
    1、成功
History     :
"""

import os
import unittest

from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger


class RowCompressTest(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.pri_sh = CommonSH('PrimaryDbUser')
        self.constant = Constant()

    def test_row_compress_pre(self):
        text = '-----step1:设置support_extended_features为on;expect:成功-----'
        self.log.info(text)
        res = self.pri_sh.execute_gsguc(
            'set', self.constant.GSGUC_SUCCESS_MSG,
            'support_extended_features=on')
        self.log.info(res)
        self.assertTrue(res, f'执行失败：{text}')
        restart_res = self.pri_sh.restart_db_cluster()
        self.log.info(restart_res)
        self.assertTrue(restart_res)
        status = self.pri_sh.get_db_cluster_status()
        self.assertTrue("Degraded" in status or "Normal" in status)

    def tearDown(self):
        text = '-----teardown:该前置用例无需清理环境，清理步骤见后置用例-----'
        self.log.info(text)
        self.log.info(f'-----{os.path.basename(__file__)} end-----')